project( model_crypto )
cmake_minimum_required( VERSION 3.0 )

# set default build type
if(NOT DEFINED CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE "Release")
endif()

if(CMAKE_SYSTEM_NAME MATCHES "Linux")
    set(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g -ggdb")
    set(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O2 -Wall")
endif()

include( CheckCXXCompilerFlag )
check_cxx_compiler_flag( "-std=c++14"   COMPILER_SUPPORTS_CXX14 )
if( COMPILER_SUPPORTS_CXX14 )
    if( CMAKE_COMPILER_IS_GNUCXX )
        set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++14" )
    else()
        set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14" )
    endif()
else()
    if( CMAKE_COMPILER_IS_GNUCXX )
        set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11" )
    else()
        set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11" )
    endif()
endif()

#########################

file(GLOB_RECURSE HEADER_FILES *.h *.hpp)
source_group("Include" FILES ${HEADER_FILES})
include_directories(../)
include_directories(${PROJECT_SOURCE_DIR}/../../openssl/include)

aux_source_directory(. DIR_SRCS)
aux_source_directory(../ DIR_SRCS)

link_directories(${PROJECT_SOURCE_DIR}/../../openssl/lib)

ADD_LIBRARY( ${PROJECT_NAME} SHARED ${DIR_SRCS})

add_executable(test_model_crypto ${DIR_SRCS})
target_link_libraries(test_model_crypto
    crypto
)

########################

INSTALL(TARGETS ${PROJECT_NAME} 
    LIBRARY DESTINATION ${PROJECT_SOURCE_DIR}/lib
    ARCHIVE DESTINATION ${PROJECT_SOURCE_DIR}/lib
)

INSTALL(TARGETS test_model_crypto 
    RUNTIME DESTINATION ${PROJECT_SOURCE_DIR}/bin
)
